home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form ScreenCap
- Caption = "Screen Capture"
- ClientHeight = 3225
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 5430
- Height = 3630
- Left = 1035
- LinkTopic = "Form2"
- ScaleHeight = 3225
- ScaleWidth = 5430
- Top = 1140
- Width = 5550
- Begin CommandButton Command2
- Caption = "Start"
- Height = 555
- Left = 4140
- TabIndex = 2
- Top = 1620
- Width = 1155
- End
- Begin CommandButton Command1
- Caption = "Ok"
- Height = 555
- Left = 4140
- TabIndex = 1
- Top = 2340
- Width = 1155
- End
- Begin PictureBox Picture1
- AutoRedraw = -1 'True
- Height = 2955
- Left = 180
- ScaleHeight = 195
- ScaleMode = 3 'Pixel
- ScaleWidth = 251
- TabIndex = 0
- Top = 180
- Width = 3795
- End
- Option Explicit
- Dim HasCapture%
- Dim StartPoint As POINTAPI
- Dim EndPoint As POINTAPI
- Dim DashedPen%
- Sub Command1_Click ()
- Unload Me
- End Sub
- Sub Command2_Click ()
- Dim di%
- Me.WindowState = 1
- di% = SetCapture(picture1.hWnd)
- End Sub
- Sub DrawScreenBox (pic As PictureBox, ByVal x1%, ByVal y1%, ByVal x2%, ByVal y2%, copyit%)
- Dim scrhwnd%, usedc%, di%, oldrop%, oldpen%
- Dim picpt1 As POINTAPI, picpt2 As POINTAPI
- Dim usewidth%, useheight%
- scrhwnd% = GetDeskTopWindow()
- usedc% = CreateDC("Display", ByVal 0&, ByVal 0&, ByVal 0&)
- oldrop% = SetROP2(usedc%, R2_XORPEN)
- oldpen% = SelectObject(usedc%, DashedPen%)
- di% = SelectObject(usedc%, GetStockObject(NULL_BRUSH))
- ' Change to screen coordinates
- picpt1.x = x1%: picpt1.y = y1%
- picpt2.x = x2%: picpt2.y = y2%
- ClientToScreen picture1.hWnd, picpt1
- ClientToScreen picture1.hWnd, picpt2
- di% = Rectangle(usedc%, picpt1.x, picpt1.y, picpt2.x, picpt2.y)
- usewidth% = picpt2.x - picpt1.x
- If picture1.ScaleWidth < usewidth% Then usewidth% = picture1.ScaleWidth
- useheight% = picpt2.y - picpt1.y
- If picture1.ScaleHeight < useheight% Then useheight% = picture1.ScaleHeight
- picture1.Cls
- di% = BitBlt(picture1.hDC, 0, 0, picpt2.x - picpt1.x, picpt2.y - picpt1.y, usedc%, picpt1.x, picpt1.y, SRCCOPY)
- di% = DeleteDC(usedc%)
- End Sub
- Sub Form_Load ()
- DashedPen% = CreatePen(PS_DOT, 1, 0)
- End Sub
- Sub Form_Resize ()
- If WindowState <> 0 Then Exit Sub
- picture1.Move 0, 0, Me.ScaleWidth - Command1.Width * 1.2, Me.ScaleHeight
- End Sub
- Sub Form_Unload (Cancel As Integer)
- Dim di%
- If DashedPen% <> 0 Then
- di% = DeleteObject(DashedPen%)
- End If
- End Sub
- Sub Picture1_MouseDown (Button As Integer, Shift As Integer, x As Single, y As Single)
- ' This conversion is safe, as we are in pixels
- If ScreenCap.WindowState = 0 Then Exit Sub
- StartPoint.x = CInt(x)
- StartPoint.y = CInt(y)
- EndPoint.x = CInt(x)
- EndPoint.y = CInt(y)
- HasCapture% = True
- End Sub
- Sub Picture1_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
- If HasCapture% Then
- DrawScreenBox picture1, StartPoint.x, StartPoint.y, EndPoint.x, EndPoint.y, False
- DrawScreenBox picture1, StartPoint.x, StartPoint.y, x, y, False
- End If
- EndPoint.x = x
- EndPoint.y = y
- End Sub
- Sub Picture1_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single)
- ' If we're not mouse tracking, exit the subroutine
- If Not HasCapture% Then Exit Sub
- DrawScreenBox picture1, StartPoint.x, StartPoint.y, EndPoint.x, EndPoint.y, True
- EndPoint.x = x
- EndPoint.y = y
- ' Blt it here
- HasCapture% = 0
- ' Restore the original drawing mode
- ScreenCap.WindowState = 0
- picture1.Refresh
- End Sub
-